﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<link href="~/Content/layerui/need/layer.css" rel="stylesheet" />
<script src="~/Content/layerui/layer.js"></script>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
</head>
<body>
    <div>
        <button onclick="dotest()">信息框</button>

    </div>
    <script type="text/javascript">
        function dotest() {
            //询问框
            layer.open({
                content: '您确定要刷新一下本页面吗？'
                , btn: ['刷新', '不要']
                , yes: function (index) {
                    layer.open({
                        type: 2
                        , content: '加载中'
                    });
                    dotest2();
                   // location.reload();
                   // layer.close(index);
                }
            });
        }
        function dotest2() {
            layer.open({
                content: '移动版和PC版不能同时存在同一页面'
                , btn: '我知道了'
            });
        }

        var data = '@Html.Raw(ViewBag.wxJsApiParam)';
        data = eval("(" + data + ")");
        var imgUrl = shareCustomerData.imgUrl;
        var lineLink = shareCustomerData.link;
        var descContent = shareCustomerData.desc;
        var shareTitle = shareCustomerData.title;
        var appid = data.appId;

        function shareFriend() {
            WeixinJSBridge.invoke('sendAppMessage', {
                "appid": appid,
                "img_url": imgUrl,
                "img_width": "200",
                "img_height": "200",
                "link": lineLink,
                "desc": descContent,
                "title": shareTitle
            }, function (res) {
                //_report('send_msg', res.err_msg);
            })
        }
        function shareTimeline() {
            WeixinJSBridge.invoke('shareTimeline', {
                "img_url": imgUrl,
                "img_width": "200",
                "img_height": "200",
                "link": lineLink,
                "desc": descContent,
                "title": shareTitle
            }, function (res) {
                //_report('timeline', res.err_msg);
            });
        }
        function shareWeibo() {
            WeixinJSBridge.invoke('shareWeibo', {
                "content": descContent,
                "url": lineLink,
            }, function (res) {
                //_report('weibo', res.err_msg);
            });
        }
        // 当微信内置浏览器完成内部初始化后会触发WeixinJSBridgeReady事件。
        document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
            // 发送给好友
            WeixinJSBridge.on('menu:share:appmessage', function (argv) {
                shareFriend();
            });
            // 分享到朋友圈
            WeixinJSBridge.on('menu:share:timeline', function (argv) {
                shareTimeline();
            });
            // 分享到微博
            WeixinJSBridge.on('menu:share:weibo', function (argv) {
                shareWeibo();
            });
        }, false);
        //分享到朋友圈
        function weixinShareTimeline(title, desc, link, imgUrl) {
            WeixinJSBridge.invoke('shareTimeline', {
                "img_url": imgUrl,
                //"img_width":"640",
                //"img_height":"640",
                "link": link,
                "desc": desc,
                "title": title
            });
        }
        //发送给好友
        function weixinSendAppMessage(title, desc, link, imgUrl) {
            WeixinJSBridge.invoke('sendAppMessage', {
                //"appid":appId,
                "img_url": imgUrl,
                //"img_width":"640",
                //"img_height":"640",
                "link": link,
                "desc": desc,
                "title": title
            });
        }
        //分享到腾讯微博
        function weixinShareWeibo(title, link) {
            WeixinJSBridge.invoke('shareWeibo', {
                "content": title + link,
                "url": link
            });
        }
        //关注指定的微信号
        function weixinAddContact(name) {
            WeixinJSBridge.invoke("addContact", { webtype: "1", username: name }, function (e) {
                WeixinJSBridge.log(e.err_msg);
                //e.err_msg:add_contact:added 已经添加
                //e.err_msg:add_contact:cancel 取消添加
                //e.err_msg:add_contact:ok 添加成功
                //WeixinJSBridge.log(d.err_msg);
                if (e.err_msg == 'add_contact:added' || e.err_msg == 'add_contact:ok') {
                    //关注成功，或者已经关注过
                }

            })
        }


        function WeiXinShareBtn() {
            if (typeof WeixinJSBridge == "undefined") {
                alert(" 请先通过微信搜索 wow36kr 添加36氪为好友，通过微信分享文章 :) ");
            } else {
                WeixinJSBridge.invoke('shareTimeline', {
                    "title": "36氪",
                    "link": "http://www.36kr.com",
                    "desc": " 关注互联网创业 ",
                    "img_url": "http://www.36kr.com/assets/images/apple-touch-icon.png"
                });
            }
        }

    </script>
</body>

</html>
